package com.jh.paymentchannel.pojo.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zhugu
 * @version 1.0
 * @Date 2019/1/3 17:36
 */
public enum PayStatus {
    WAIT_WITHDRAW("0", "待提现"),
    WITHDRAW_SUCCESS("1", "提现成功"),
    WITHDRAW_FAIL("2", "提现失败"),
    WITHDRAW_EXCEPTION("3", "提现异常"),
    WITHDRAW_ING("4", "提现中"),
    ;
    private final String value;
    private final String desc;

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    PayStatus(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static PayStatus of(String n) {
        String val;
        if (StringUtils.isEmpty(n)) {
            return null;
        }
        val = n;

        for (PayStatus payStatus : values()) {
            if (val.equals(payStatus.getValue())) {
                return payStatus;
            }
        }

        for (PayStatus payStatus : values()) {
            if (val.equals(payStatus.getDesc())) {
                return payStatus;
            }
        }

        return null;
    }
}
